<template>
  <div class="login-vue">
    <div class="login-container">
      <div class="login-content">
        <div class="login-title">{{ title }}</div>
        <div class="login-input">
          <input type="text" name="username" v-model="username" autocomplete="off"/>
          <span class="placeholder" :class="{fixed: username != '' && username != null}">用户名</span>
        </div>
        <div class="login-password login-input">
          <input type="password" name="password" v-model="password" autocomplete="off"/>
          <span class="placeholder" :class="{fixed: password != '' && password != null}">密码</span>
        </div>
        <div class="login-input">
          <input type="text" name="verify" v-model="verify" @keyup.enter="submit" autocomplete="off" style="width: 150px"/>
          <span class="placeholder" :class="{fixed: verify != '' && verify != null}">验证码</span>
          <img style="width: 100px;height:40px;cursor: pointer;" :src="verifyUrl" @click="updateVerify"/>
        </div>
        <div class="buttonDiv">
          <Button :loading="loading" block color="primary" size="l" @click="submit">登录</Button>
        </div>
        <div class="buttonDiv">
          <Button @click="showDlg=true"  block color="primary" size="l">Element UI Demo</Button>
        </div>
      </div>
    </div>
    <Modal v-model="showDlg">
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="活动名称">
            <el-input v-model="form.name"></el-input>
          </el-form-item>
          <el-form-item label="活动区域">
            <el-select v-model="form.region" placeholder="请选择活动区域">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="活动时间">
            <el-col :span="11">
              <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
            </el-col>
            <el-col class="line" :span="2">-</el-col>
            <el-col :span="11">
              <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="即时配送">
            <el-switch v-model="form.delivery"></el-switch>
          </el-form-item>
          <el-form-item label="活动性质">
            <el-checkbox-group v-model="form.type">
              <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
              <el-checkbox label="地推活动" name="type"></el-checkbox>
              <el-checkbox label="线下主题活动" name="type"></el-checkbox>
              <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="特殊资源">
            <el-radio-group v-model="form.resource">
              <el-radio label="线上品牌商赞助"></el-radio>
              <el-radio label="线下场地免费"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="活动形式">
            <el-input type="textarea" v-model="form.desc"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">立即创建</el-button>
            <el-button @click="showDlg=false">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </Modal>
  </div>
</template>
<script>
import Vue from 'vue';
console.log(Vue);
import pk from 'axios'
console.log(pk)
export default {
  name: "Login",
  data: function () {
    return {
      title: '测试页面',
      showDlg:false,
      username:'',
      password: '',
      verify:'',
      loading: false,
      verifyUrl:'https://img1.baidu.com/it/u=2995143552,1363900887&fm=26&fmt=auto&t='+new Date().getTime(),
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    };
  },
  methods: {
    updateVerify(){
     // this.verifyUrl='captcha?t='+new Date().getTime();
      this.verify=''
    },submit: function () {
      if (!this.password) {
        this.$Message("密码不能为空");
        return;
      }
      if (!this.verify) {
        this.$Message("验证码不能为空");
        return;
      }
      if (this.verify.length!=5) {
        this.$Message("验证码长度为5位");
        return;
      }
      this.loading = true;
      setTimeout(()=>{
        this.loading=false
      },3000)
    },
    onSubmit() {
      console.log('submit!');
    }
  }
};
</script>
<style>
.login-vue {
  text-align: center;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background: #f7f8fa;
}

.login-vue .login-container {
  width: 320px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.login-vue .login-container .login-content {
  letter-spacing: 2px;
  background: #FFF;
  padding: 70px 30px 20px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  box-sizing: border-box;
}

.login-vue .login-container .login-content > div {
  margin: 30px 0;
}

.login-vue .login-container .login-content > div.login-input {
  position: relative;
}

.login-vue .login-container .login-content > div.login-input .placeholder {
  position: absolute;
  color: #7e7e7e;
  top: 6px;
  font-size: 16px;
  transition: all .2s;
  left: 0;
  pointer-events: none;
}

.login-vue .login-container .login-content > div.login-input input {
  font-size: 16px;
  padding: 8px 0;
  height: 40px;
  width: 100%;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid #d3d3d3;
  box-shadow: inset 0 0 0 1000px #fff;
  outline: none;
  box-sizing: border-box;
  transition: .3s;
  font-weight: 200;
}

.login-vue .login-container .login-content > div.login-input input:focus {
  border-bottom-color: #3788ee;
  box-shadow: inset 0 0 0 1000px #fff;
}

.login-vue .login-container .login-content > div.login-input input:focus + .placeholder,
.login-vue .login-container .login-content > div.login-input .placeholder.fixed {
  font-size: 13px;
  top: -16px;
}

.login-vue .login-container .login-content > div.login-input input:-webkit-autofill + .placeholder {
  font-size: 13px;
  top: -16px;
}

.login-vue .login-container .login-content > div.login-title {
  font-size: 30px;
  color: #3a3a3a;
  line-height: 1;
  margin: -16px 0px 40px;
  font-weight: 200;
}

.login-vue .login-container .login-content > .buttonDiv {
  margin-top: 45px;
}

.login-vue .login-container .login-content > .buttonDiv .h-btn {
  padding: 12px 0;
  font-size: 18px;
  opacity: .8;
  border-radius: 3px;
  background: #3788ee;
  border-color: #3788ee;
}

.login-vue .login-container .login-content > .buttonDiv .h-btn:hover {
  opacity: 1;
  background: #3788ee;
  border-color: #3788ee;
}

.login-vue .login-container .copyright {
  letter-spacing: 1px;
  margin-top: 30px;
  color: #7e7e7e;
}

.login-vue .login-container .copyright a {
  color: #7e7e7e;
}

</style>
